home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / asm / pack / imploder / imp_packer.s < prev    next >
Text File  |  1980-01-03  |  22KB  |  1,207 lines

  1. ******************************************************************************
  2. * IMP! (IMP!) Multi-selection capable data-compressor
  3. * ----------------------------------------------------------------------------
  4. * Just a simple reqtools front end tacked onto the Imploder algorithm for
  5. * data compression. Decent compression, very good on decompression speed.
  6. *
  7. * THE IMP! ALGORITHM IS FULLY *FREEWARE* AND IS SUPPLIED WITH THE FREEWARE
  8. * BEERMON MONITOR PACKAGE. YOU CAN USE IT IN ANY PRODUCTIONS YOU LIKE 
  9. ******************************************************************************
  10. HeaderID    =    "IMP!"        ;also recognised as "ATN!"
  11.  
  12.         rsreset
  13. _DOSBase:    rs.l    1
  14. _RTBase:    rs.l    1
  15. ProgHandle:    rs.l    1
  16. ProgBuff:    rs.l    1
  17. ProgSize:    rs.l    1
  18. TotalGain    rs.l    1
  19. filereq        rs.l    1
  20. volreq        rs.l    1
  21. flist        rs.l    1
  22. Savename    rs.l    1
  23. PackedSize    rs.l    1
  24. Array        rs.l    6
  25. valbuf:        rs.b    20
  26. hexbuff        rs.b    10
  27. Buffer        rs.b    128
  28. filename    rs.b    34
  29. finalname:    rs.b    256
  30. volpath:    rs.b    128
  31. vars_SIZEOF    rs.b    0
  32.         rsreset
  33.  
  34.         section    multiselect,code
  35.  
  36.         include    'includes:misc/os3_gst.i'
  37.  
  38.         link    a4,#-vars_SIZEOF
  39.         move.l    #vars_SIZEOF-1,d7
  40. clear_bss:    clr.b    -(a4)
  41.         dbra    d7,clear_bss
  42.         
  43. *-------------- Open dos library..
  44.  
  45.         move.l    4.w,a6
  46.         lea    DOSName(pc),a1
  47.         CALL    OldOpenLibrary
  48.         move.l    d0,_DOSBase(a4)
  49.         beq.w    NoLib
  50.  
  51.         lea    About.txt(pc),a0
  52.         bsr.w    putstr
  53.  
  54. *-------------- Open reqtools library..
  55.  
  56.         lea    ReqName(pc),a1
  57.         CALL    OldOpenLibrary
  58.         move.l    d0,_RTBase(a4)
  59.         beq.w    closedos
  60.         move.l    d0,a6
  61.  
  62. *-------------- Allocate a Reqtools File Requester
  63.  
  64.         move.l    #RT_FILEREQ,d0
  65.         suba.l    a0,a0
  66.         CALL    rtAllocRequestA
  67.         move.l    d0,filereq(a4)
  68.         beq.w    ok17
  69.  
  70. *-------------- multiselect some filenames...
  71.  
  72.         move.l    filereq(a4),a1
  73.         lea    filename(a4),a2
  74.         lea    Text66(pc),a3
  75.         lea    Tags9(pc),a0
  76.         CALL    rtFileRequestA
  77.         move.l    d0,flist(a4)
  78.         beq.w    ok16
  79.  
  80. *-------------- allocate a volume requester..
  81.  
  82.         move.l    #RT_FILEREQ,d0
  83.         sub.l    a0,a0
  84.         CALL    rtAllocRequestA
  85.         move.l    d0,volreq(a4)
  86.         beq.w    freelist            ;free multilist..
  87.  
  88. *-------------- select destination path..
  89.  
  90.         lea    volpath(a4),a1
  91.         clr.b    (a1)
  92.  
  93.         suba.l    a2,a2
  94.         lea    Text89(pc),a3
  95.         lea    Tags11(pc),a0
  96.         move.l    volreq(a4),a1
  97.         CALL    rtFileRequestA
  98.         tst.l    d0
  99.         beq.s    vol_error
  100.  
  101. *-------------- selection ok...
  102.  
  103.         move.l    volreq(a4),a0
  104.         move.l    rtfi_Dir(a0),a0
  105.         lea    volpath(a4),a1
  106. get_volname:    move.b    (a0)+,(a1)+
  107.         bne.s    get_volname
  108.         bra.s    vol_free
  109.  
  110. *-------------- selection cancelled or failed..
  111.  
  112. vol_error    lea    NoPath.txt(pc),a0
  113.         bsr.w    putstr
  114.  
  115. vol_free    move.l    volreq(a4),a1
  116.         CALL    rtFreeRequest
  117.  
  118. *-------------- process all filenames in the list...
  119.  
  120.         clr.l    TotalGain(a4)
  121.         
  122.         move.l    flist(a4),a6
  123. nextfile:
  124.         lea    finalname(a4),a5
  125.         move.l    a5,a1
  126.  
  127.         move.l    filereq(a4),a0
  128.         move.l    rtfi_Dir(a0),d0
  129.         beq.s    no_slash
  130.         move.l    d0,a0
  131.         move.l    rtfl_Name(a6),d1
  132.         beq.s    nextname
  133.         
  134. bytecopy:    move.b    (a0)+,(a1)+
  135.         bne.s    bytecopy
  136.         cmp.b    #":",-2(a1)
  137.         bne.s    add_slash
  138.         tst.b    -(a1)
  139.         bra.s    no_slash
  140. add_slash:    tst.b    -(a1)
  141.         move.b    #"/",(a1)+
  142. no_slash:    move.l    d1,a0
  143. bytecopy2:    move.b    (a0)+,(a1)+
  144.         bne.s    bytecopy2
  145.         clr.b    (a1)+
  146.         move.l    a5,d0
  147.  
  148. *-------------- d0.l = final filename..
  149.  
  150.         bsr.s    process            ;process files in linked list.
  151.         tst.l    d0            ;abort processing of files??
  152.         bne.s    aborted
  153.  
  154. nextname    move.l    rtfl_Next(a6),a6
  155.         cmp.l    #0,a6
  156.         bne.s    nextfile
  157.  
  158.         move.l    TotalGain(a4),d0
  159.         lea    TotGain.Txt(pc),a0
  160.         bsr.w    putstr            ;d0.l = Gained bytes
  161.         bsr.w    H2A
  162.  
  163.         lea    Done.txt(pc),a0
  164.         bsr.w    putstr
  165.  
  166. *-------------- free list of filenames..
  167.  
  168. freelist
  169. aborted        move.l    flist(a4),a0
  170.         move.l    _RTBase(a4),a6
  171.         CALL    rtFreeFileList
  172.  
  173. *-------------- free file requesters..
  174.  
  175. ok16        move.l    filereq(a4),a1
  176.         CALL    rtFreeRequest
  177.  
  178. *-------------- close reqtools library..
  179.  
  180. closelibs
  181. ok17        move.l    _RTBase(a4),a1
  182.         move.l    4.w,a6
  183.         CALL    CloseLibrary
  184.  
  185. *-------------- close dos library..
  186.  
  187. closedos:    move.l    _DOSBase(a4),a1
  188.         move.l    4.w,a6
  189.         CALL    CloseLibrary
  190.  
  191. NoLib:        lea    vars_SIZEOF(a4),a4        * Restore stack memory!
  192.         unlk    a4
  193.         moveq    #0,d0
  194.         rts
  195.  
  196.  
  197.  
  198.  
  199. process        movem.l    d1-d7/a0-a6,-(sp)
  200.  
  201. *-------------- Attempt to load this file..
  202.  
  203. LoadFile:    move.l    d0,-(sp)
  204.         lea    Load.txt(pc),a0
  205.         bsr.w    putstr
  206.         move.l    (sp),a0
  207.         bsr.w    putstr
  208.         lea    LF.txt(pc),a0
  209.         bsr.w    putstr
  210.         move.l    (sp),a0
  211.         bsr.w    LoadDOSFile
  212.         move.l    (sp)+,a0
  213.         tst.l    d0
  214.         beq.s    Load_Okay
  215.  
  216.         cmp.l    #-2,d0
  217.         bne.s    notf
  218.  
  219. *-------------- out of memory
  220.  
  221.         move.l    a0,-(sp)
  222.         lea    ErrorMem.txt(pc),a0
  223.         bsr.w    putstr
  224.         move.l    (sp)+,a0
  225.         bra.w    nosave
  226.  
  227. *-------------- file not found
  228. notf
  229.         move.l    a0,-(sp)
  230.         lea    ErrorLoad.txt(pc),a0
  231.         bsr.w    putstr
  232.         move.l    (sp)+,a0
  233.         bra.w    nosave
  234.  
  235. Load_Okay:
  236.         move.l    a0,-(sp)
  237.         lea    Packing.txt(pc),a0
  238.         bsr.w    putstr
  239.         move.l    (sp)+,a0
  240.  
  241.         bsr.w    sort_destname
  242.  
  243.         move.l    d0,-(sp)
  244.         move.l    ProgBuff(a4),a0
  245.         move.l    ProgSize(a4),d0
  246.         move.l    #11,d1
  247.         bsr.w    _compress_slow
  248.         move.l    (sp)+,a0        ;a0=filename..
  249.  
  250.         move.l    a0,Savename(a4)
  251.         move.l    d0,PackedSize(a4)
  252.         bne.s    packedokay    
  253.                     
  254.         lea    ErrorGain.txt(pc),a0
  255.         bsr.w    putstr
  256.         bra.w    nosave
  257.  
  258. packedokay
  259. *-------------- show packed statistics..
  260.  
  261.         move.l    ProgSize(a4),d0
  262.         lea    OrigLength.Txt(pc),a0
  263.         bsr.w    putstr
  264.         bsr.w    H2A
  265.  
  266.         move.l    PackedSize(a4),d0
  267.         lea    PakLength.Txt(pc),a0
  268.         bsr.w    putstr
  269.         bsr.w    H2A
  270.  
  271.         move.l    ProgSize(a4),d0        ;original size
  272.         sub.l    PackedSize(a4),d0    ;d0.l = gain in bytes.
  273.         add.l    d0,TotalGain(a4)
  274.  
  275.         lea    Gained.Txt(pc),a0
  276.         bsr.w    putstr            ;d0.l = Gained bytes
  277.         bsr.w    H2A
  278.  
  279.         move.l    PackedSize(a4),d0    ;d0.l = Packed size
  280.         move.l    ProgSize(a4),d1        ;d1.l = Original size
  281.         move.l    d1,d2
  282.         sub.l    d0,d2
  283.         move.l    d1,d3
  284. getgain1:    tst.l    d2
  285.         bmi.s    getgain2
  286.         tst.l    d3
  287.         bmi.s    getgain2
  288.         add.l    d2,d2
  289.         add.l    d3,d3
  290.         bra.s    getgain1
  291.  
  292. getgain2:    lsr.l    #1,d2
  293.         lsr.l    #1,d3
  294.         clr.w    d2
  295.         clr.w    d3
  296.         swap    d2
  297.         swap    d3
  298.         mulu    #100,d2
  299.         divu    d3,d2
  300.  
  301. *-------------- d2.w = % gain
  302. ;        d0.l = old size
  303. ;        d1.l = new size
  304.  
  305.         lea    Percentage.Txt(pc),a0
  306.         bsr.w    putstr            ;d0.l = Gained bytes
  307.  
  308.         moveq    #0,d0
  309.         move.w    d2,d0
  310.         move.l    d2,-(sp)
  311.         lea    valbuf(a4),a0
  312.         bsr.w    hex2asc
  313.         bsr.w    putstr
  314.  
  315.         lea    valbuf(a4),a0
  316.         move.w    #$2E00,(a0)
  317.         bsr.w    putstr
  318.  
  319.         lea    valbuf(a4),a0
  320.         move.l    (sp)+,d0
  321.         clr.w    d0
  322.         swap    d0
  323.         bsr.w    hex2asc
  324.         sf.b    2(a0)
  325.         bsr.w    putstr
  326.  
  327.         lea    valbuf(a4),a0
  328.         move.w    #$2500,(a0)
  329.         bsr.w    putstr
  330.  
  331.         lea    LF.txt(pc),a0
  332.         bsr.w    putstr
  333.  
  334. *-------------- Attempt to save this file..
  335.  
  336. SaveFile:
  337.         lea    Save.txt(pc),a0
  338.         bsr.w    putstr
  339.         move.l    Savename(a4),a0
  340.         bsr.w    putstr
  341.         lea    LF.txt(pc),a0
  342.         bsr.b    putstr
  343.  
  344. *-------------- write file out..
  345.  
  346.         move.l    Savename(a4),a0
  347.         move.l    ProgBuff(a4),a1
  348.         move.l    PackedSize(a4),d1
  349.         bsr.w    SaveDOSFile
  350.         tst.l    d0
  351.         beq.s    Save_Okay
  352.  
  353.         lea    ErrorSave.txt(pc),a0
  354.         bsr.b    putstr
  355. Save_Okay
  356.  
  357. nosave        bsr.w    FreeDOSFile
  358.  
  359. *-------------- abort processing of files if CTRL+C was pressed...
  360.  
  361.         bsr.b    _CheckBreak
  362.  
  363.         movem.l    (sp)+,d1-d7/a0-a6
  364.         rts
  365.  
  366.  
  367. _CheckBreak:    moveq    #0,d0
  368.         moveq    #0,d1
  369.         bset.l    #SIGBREAKB_CTRL_C,d1    ;check for CTRL_C
  370.         move.l    _DOSBase(a4),a6
  371.         CALL    CheckSignal        ;did user signal a break??
  372.  
  373.         btst.l    #SIGBREAKB_CTRL_C,d0
  374.         beq.s    NoBreak
  375. WasBroken:    moveq    #1,d0            ;yes.. user tried to break..
  376.         rts
  377.  
  378. NoBreak:    moveq    #0,d0            ;no break
  379.         rts
  380.  
  381.  
  382.  
  383.  
  384. sort_destname:    lea    volpath(a4),a3
  385.         lea    finalname(a4),a5
  386.         move.l    a5,a1
  387.         move.l    a3,a0
  388.         move.l    rtfl_Name(a6),d1
  389.         beq.w    nextname
  390. _bytecopy:    move.b    (a0)+,(a1)+
  391.         bne.s    _bytecopy
  392.         cmp.b    #":",-2(a1)
  393.         bne.s    _add_slash
  394.         tst.b    -(a1)
  395.         bra.s    _no_slash
  396. _add_slash:    tst.b    -(a1)
  397.         move.b    #"/",(a1)+
  398. _no_slash:    move.l    d1,a0
  399. _bytecopy2:    move.b    (a0)+,(a1)+
  400.         bne.s    _bytecopy2
  401.         clr.b    (a1)+
  402.         move.l    a5,d0
  403.         rts
  404.  
  405. *-------------- returns d0.l = filename..
  406.  
  407. * Putstr
  408. *
  409. * Sends a ascii text string to current console output
  410. * $Inputs:    a0.l = String ptr (null terminated)
  411.  
  412. putstr:        movem.l    d0-d7/a1-a6,-(sp)
  413.         move.l    a0,d2
  414.         moveq    #-1,d3            ;d4=0
  415. getlen3        addq.l    #1,d3            ;increase string length by 1
  416.         tst.b    (a0)+            ;increase position
  417.         bne.s    getlen3            ;nope not found, so keep on
  418.         move.l    _DOSBase(a4),a6
  419.         CALL    Output            ;get output base
  420.         move.l    d0,d1
  421.         CALL    Write            ;print error msg to cli
  422.         movem.l    (sp)+,d0-d7/a1-a6
  423.         rts
  424.                 
  425. * _LoadDOSFile :- Loads an AmigaDOS file from any device into memory
  426. *
  427. * In        a0 (.L)    = Filename
  428. *
  429. * Out        d0 (.L) = Result Code (0=File Ok,-1=Load Failed!)    
  430. *        d1 (.L) = Length
  431.     
  432. LoadDOSFile:    movem.l    d2-d7/a0/a2-a6,-(sp)
  433.         clr.l    ProgHandle(a4)
  434.         clr.l    ProgBuff(a4)
  435.         clr.l    ProgSize(a4)
  436.  
  437. *-------------- Open file
  438.         move.l    a0,d1            ;get filename
  439.         move.l    #MODE_OLDFILE,d2
  440.         move.l    _DOSBase(a4),a6
  441.         CALL    Open            ;open file
  442.         move.l    d0,ProgHandle(a4)
  443.         beq.s    NotFound
  444.  
  445. *-------------- Get Length of file
  446.  
  447.         move.l    d0,d5            ;ProgHandle
  448.         move.l    d5,d1            ;file handle
  449.         moveq    #0,d2
  450.         moveq    #1,d3
  451.         CALL    Seek            ;seek start of file
  452.         move.l    d5,d1            ;file handle
  453.         moveq    #0,d2
  454.         moveq    #-1,d3
  455.         CALL    Seek            ;seek end of file
  456.         move.l    d0,ProgSize(a4)
  457.  
  458. *-------------- Allocate Memory for file
  459.  
  460.         move.l    4.w,a6            ;get execbase
  461.         move.l    #MEMF_PUBLIC,d1        ;we want public mem
  462.         CALL    AllocVec        ;allocate it...
  463.         move.l    d0,ProgBuff(a4)        ;save base
  464.         beq.b    TooBig            ;fail?
  465.  
  466. *-------------- Load in whole file
  467.                 
  468.         move.l    ProgHandle(a4),d1
  469.         move.l    ProgBuff(a4),d2
  470.         move.l    ProgSize(a4),d3
  471.         move.l    _DOSBase(a4),a6
  472.         CALL    Read            ;read file
  473.  
  474. *-------------- Close file
  475.  
  476. CloseFile:    move.l    ProgHandle(a4),d1
  477.         CALL    Close            ;close file
  478.  
  479.         move.l    ProgSize(a4),d1        ;d1=ProgSize
  480.         move.l    ProgBuff(a4),a1        
  481.  
  482.         movem.l    (sp)+,d2-d7/a0/a2-a6
  483.         moveq    #0,d0            ;resultcode (okay)
  484.         rts
  485.  
  486. NotFound:    movem.l    (sp)+,d2-d7/a0/a2-a6
  487.         moveq    #-1,d0            ;file not found error-code
  488.         rts
  489.  
  490. TooBig:        move.l    ProgHandle(a4),d1
  491.         move.l    _DOSBase(a4),a6
  492.         CALL    Close            ;close file
  493.         movem.l    (sp)+,d2-d7/a0/a2-a6
  494.         moveq    #-2,d0            ;file too big error-code
  495. NotAlloc    rts
  496.  
  497.  
  498.  
  499.  
  500. *-------------- Free Memory for DOSFile
  501.  
  502. FreeDOSFile:    move.l    (AbsExecBase).w,a6    ;get execbase
  503.  
  504.         move.l    ProgBuff(a4),d0        ;ptr to our RS.Variables base
  505.         beq.s    NotAlloc1
  506.         move.l    d0,a1
  507.         CALL    FreeVec            ;free the memory
  508.         clr.l    ProgBuff(a4)
  509.         clr.l    ProgSize(a4)
  510.  
  511. NotAlloc1:    rts
  512.  
  513. * SaveMem2File
  514. *
  515. * $Inputs:    a0.l    = Filename
  516. *        a1.l    = Mem Address
  517. *        d1.l    = Save Length
  518. *
  519. * $Outputs:    d0.l    = 0 - success
  520. *        d0.l    = 1 - failure
  521.  
  522. SaveDOSFile:    movem.l    d2-d7/a0-a6,-(sp)
  523.         move.l    a1,d5            ;progbuffer
  524.         move.l    d1,d6            ;proglength
  525.         beq.s    _NoGain
  526.  
  527.         move.l    a0,d1            ;filename
  528.         move.l    #MODE_NEWFILE,d2
  529.         move.l    _DOSBase(a4),a6
  530.         CALL    Open
  531.         move.l    d0,d7
  532.         beq.b    _SaveError
  533.  
  534.         move.l    d7,d1            ;fh...
  535.         move.l    d5,d2            ;adr
  536.         move.l    d6,d3            ;length
  537.         CALL    Write            ;write file
  538.  
  539.         move.l    d7,d1
  540.         CALL    Close            ;close file
  541. _NoGain:    movem.l    (sp)+,d2-d7/a0-a6
  542.         moveq    #0,d0
  543.         rts
  544. _SaveError:    movem.l    (sp)+,d2-d7/a0-a6
  545.         moveq    #1,d0
  546.         rts
  547.  
  548.  
  549.  
  550. H2A:        lea    valbuf(a4),a0
  551. Hex2ASCIIDec:    bsr.b    hex2asc
  552.         bsr.w    putstr
  553.         lea    LFs.Txt(pc),a0
  554.         bra.w    putstr
  555.  
  556. hex2asc        lea    hextable(pc),a1
  557.         move.b    #"0",d6            ; constant
  558.         moveq    #9-1,d4
  559.         move.b    #" ",d5            ; replace leading 0's
  560. ccloop        move.l    (a1)+,d1
  561.         cmp.l    d1,d0
  562.         bcs.s    get3
  563.          move.w    #32-1,d3
  564.         moveq    #0,d2
  565. get1        add.l    d0,d0
  566.         roxl.l    #1,d2
  567.         cmp.l    d1,d2
  568.         bcs.s    get2
  569.         sub.l    d1,d2
  570.         addq.l    #1,d0
  571. get2        dbra    d3,get1
  572.         add.b    d6,d0
  573.         move.b    d0,(a0)+
  574.         move.l    d2,d0
  575.         move.b    d6,d5
  576.         bra.s    get4
  577.  
  578. get3        move.b    d5,(a0)+
  579. get4        dbra    d4,ccloop
  580.          add.b    d6,d0
  581.         move.b    d0,(a0)+
  582.         lea    valbuf(a4),a0
  583. .getstart    cmp.b    #" ",(a0)+
  584.         beq.s    .getstart
  585.         tst.b    -(a0)
  586.         rts
  587.  
  588. hextable    dc.l    1000000000
  589.         dc.l    100000000
  590.         dc.l    10000000
  591.         dc.l    1000000
  592.         dc.l    100000
  593.         dc.l    10000
  594.         dc.l    1000
  595.         dc.l    100
  596.         dc.l    10
  597.         dc.l    1
  598.         dc.l    0
  599.  
  600. * ATN Header (Imploder)
  601. *
  602. * In:    a0.l=*buffer
  603. *    d0.l=data length
  604. *    d1.l=crunch mode
  605. *
  606. * Out:    d0.l=<>0:crunched length
  607.  
  608. CacheFlush:    movem.l    d0-d7/a0-a6,-(sp)
  609.         move.l    4.w,a6
  610.         cmp.w    #37,$14(a6)
  611.         bcs.s    no_flush
  612.         CALL    CacheClearU
  613. no_flush:    movem.l    (sp)+,d0-d7/a0-a6
  614.         rts
  615.  
  616.         cnop    0,4
  617. _compress_slow:    movem.l    d2-d7/a2-a6,-(sp)
  618.  
  619.         moveq    #88-1,d2
  620. atn01:        clr.w    -(sp)
  621.         dbf    d2,atn01
  622.         move.l    sp,a6
  623.  
  624.         cmp.l    #$40,d0
  625.         blo.w    atn23
  626.  
  627.         scs    (a6)
  628.         move.l    a0,10(a6)
  629.         move.l    a0,$22(a6)
  630.         move.l    a0,$26(a6)
  631.         move.l    d0,$12(a6)
  632.         add.l    d0,a0
  633.         move.l    a0,14(a6)
  634.         lea    atntab0(pc),a0
  635.         lsl.w    #2,d1
  636.         move.l    0(a0,d1.w),d1
  637.         addq.l    #1,d1
  638.         cmp.l    d0,d1
  639.         bls.s    atn03
  640.  
  641.         move.l    d0,d1
  642.         subq.l    #1,d1
  643. atn03:        move.l    d1,$1A(a6)
  644.         subq.l    #1,d1
  645.         moveq    #0,d0
  646. atn04:        cmp.l    (a0)+,d1
  647.         bls.s    atn05
  648.         addq.b    #1,d0
  649.         bra.s    atn04
  650.  
  651. atn05:        move.b    d0,1(a6)
  652.         lea    $A4(a6),a1
  653.         moveq    #12,d1
  654.         mulu    d1,d0
  655.         lea    atntab1(pc),a0
  656.         add.l    d0,a0
  657.         subq.w    #1,d1
  658. atn06:        move.b    (a0)+,(a1)+
  659.         dbf    d1,atn06
  660.  
  661.         lea    $74(a6),a1
  662.         lea    $A4(a6),a0
  663.         moveq    #12-1,d1
  664. atn07:        move.b    (a0)+,d0
  665.         moveq    #0,d2
  666.         bset    d0,d2
  667.         move.l    d2,(a1)+
  668.         dbf    d1,atn07
  669.  
  670.         lea    $74(a6),a0
  671.         lea    $84(a6),a1
  672.         moveq    #8-1,d1
  673. atn08:        move.l    (a0)+,d0
  674.         add.l    d0,(a1)+
  675.         dbf    d1,atn08
  676.  
  677.         tst.b    (a6)
  678.         beq.s    atn11
  679.  
  680.         lea    $74(a6),a1
  681.         moveq    #8-1,d0
  682. atn09:        move.l    (a1)+,d1
  683.         move.w    d1,(a2)+
  684.         dbf    d0,atn09
  685.  
  686.         lea    $A4(a6),a1
  687.         moveq    #12-1,d0
  688. atn10:        move.b    (a1)+,(a2)+
  689.         dbf    d0,atn10
  690.  
  691. atn11:        move.b    #7,$2D(a6)
  692. atn12:
  693.         bsr.w    atn28
  694.         beq.s    atn15
  695.  
  696.         bsr.w    atn55
  697.         bne.s    atn13
  698.  
  699.         lea $1e(a6),a5
  700.         addq.l #1,(a5)+        ;$1e
  701.         move.l (a5),a0        ;$22
  702.         addq.l #1,(a5)+        ;$22
  703.         move.l (a5),a1        ;$26
  704.         move.b (a0),(a1)
  705.         addq.l #1,(a5)        ;$26
  706.         addq.l #1,$30(a6)    ;$30    
  707.  
  708.         cmp.l #$4012,$30(a6)
  709.         blo.s    atn12
  710.         bra.s    atn15
  711.  
  712. atn13:        move.b    $5C(a6),d0
  713.         move.l    $60(a6),d1
  714.         bsr.w    atn37
  715.         move.b    $5E(a6),d0
  716.         move.w    $66(a6),d1
  717.         bsr.w    atn37
  718.         move.b    $5D(a6),d0
  719.         move.w    $64(a6),d1
  720.         cmp.b    #13,d0
  721.         bne.s    atn14
  722.         move.l    $26(a6),a0
  723.         move.b    d1,(a0)+
  724.         move.l    a0,$26(a6)
  725.         moveq    #5,d0
  726.         moveq    #$1F,d1
  727.  
  728. atn14:        bsr.w    atn37
  729.         moveq    #0,d0
  730.         move.l d0,$30(a6)    ;clr.l    $30(a6)
  731.         move.b    $2E(a6),d0
  732.         add.l    d0,$22(a6)
  733.         bra.b    atn12
  734.  
  735.         cnop    0,4
  736. atn15:        lea $1e(a6),a5
  737.         addq.l #1,(a5)+        ;$1e
  738.         move.l (a5),a0        ;$22
  739.         addq.l #1,(a5)        ;$22
  740.         move.l (a5)+,d0        ;$22
  741.         move.l (a5),a1        ;$26
  742.         move.b (a0),(a1)
  743.         addq.l #1,(a5)        ;$26
  744.         addq.l #1,$30(a6)    ;$30
  745.  
  746.         cmp.l    14(a6),d0
  747.         bne.s    atn15
  748.  
  749.         tst.b    (a6)
  750.         bne.w    atn19
  751.         move.l    $26(a6),d0
  752.         sub.l    10(a6),d0
  753.         moveq    #12,d1
  754.         cmp.l    d1,d0        ;cmp.l #12,d0
  755.         blo.w    atn23
  756.  
  757.         move.l    $12(a6),d1
  758.         sub.l    d0,d1
  759.         moveq    #$36,d7
  760.         cmp.l    d7,d1        ;cmp.l    #$36,d1
  761.         bls.w    atn23
  762.         move.l    10(a6),a1
  763.         move.l    $26(a6),a0
  764.         move.w    #$ff00,d7    ;move.l    #$FF00,d7
  765.         btst    #0,d0
  766.         beq.s    atn16
  767.         moveq    #0,d7
  768.         addq.l    #1,d0
  769.         clr.b    (a0)+
  770. atn16:        move.l    (a1),8(a0)
  771.         move.l    #HeaderID,(a1)
  772.         move.l    4(a1),4(a0)
  773.         move.l    $12(a6),4(a1)
  774.         move.l    8(a1),(a0)
  775.         move.l    d0,8(a1)
  776.         moveq    #$2e,d1
  777.         add.l    d1,d0        ;add.l    #$2E,d0
  778.         move.l    d0,$16(a6)
  779.         move.l    $30(a6),12(a0)
  780.         move.b    $2C(a6),d1
  781.         and.w    #$FE,d1
  782.         move.b    $2D(a6),d0
  783.         bset    d0,d1
  784.         or.w    d7,d1
  785.         move.w    d1,$10(a0)
  786.  
  787.         lea    $74(a6),a1
  788.         lea    $12(a0),a0
  789.         moveq    #8-1,d0
  790. atn17:        move.l    (a1)+,d1
  791.         move.w    d1,(a0)+
  792.         dbf    d0,atn17
  793.  
  794.         lea    $A4(a6),a1
  795.         moveq    #12-1,d0
  796. atn18:        move.b    (a1)+,(a0)+
  797.         dbf    d0,atn18
  798.         bra.s    atn23
  799.  
  800.         cnop    0,4
  801. atn19:        move.l    $26(a6),d0
  802.         sub.l    10(a6),d0
  803.         move.l    $12(a6),d1
  804.         sub.l    d0,d1
  805.         moveq #6,d2
  806.         cmp.l d2,d1        ;cmp.l    #6,d1
  807.         bls.s    atn23
  808.  
  809.         move.b    $2C(a6),d1
  810.         and.b    #$FE,d1
  811.         move.b    $2D(a6),d2
  812.         bset    d2,d1
  813.         move.l    $26(a6),a0
  814.         btst    #0,d0
  815.         beq.s    atn20
  816.         move.b    d1,(a0)+
  817.         move.l    $30(a6),(a0)
  818.         bra.s    atn21
  819.  
  820.         cnop    0,4
  821. atn20:        move.l    $30(a6),(a0)+
  822.         move.b    d1,(a0)
  823. atn21:        addq.l    #5,d0
  824.         move.l    d0,$16(a6)
  825.         bra.s    atn23
  826.  
  827. atn22:        moveq    #-1,d0
  828.         bra.s    atn24
  829.  
  830.         cnop    0,4
  831. atn23:        move.l    $16(a6),d0
  832. atn24:        moveq    #88-1,d2
  833. atn25:        clr.w    (sp)+
  834.         dbf    d2,atn25
  835.  
  836.         movem.l    (sp)+,d2-d7/a2-a6
  837.         bsr.w    CacheFlush
  838.         tst.l    d0
  839.         rts
  840.  
  841. atntab0:    dc.l    128
  842.         dc.l    256
  843.         dc.l    512
  844.         dc.l    1024
  845.         dc.l    1792
  846.         dc.l    3328
  847.         dc.l    5376
  848.         dc.l    9472
  849.         dc.l    20736
  850.         dc.l    37376
  851.         dc.l    67840
  852.         dc.l    67840
  853.  
  854. atntab1:    dc.l    $5050505,$5050505,$6060606,$5060707,$6060606,$7070606
  855.         dc.l    $5060707,$7070707,$8080808,$5060708,$7070808,$8080909
  856.         dc.l    $6070708,$7080909,$8090A0A,$6070708,$709090A,$80A0B0B
  857.         dc.l    $6070808,$709090A,$80A0B0C,$6070808,$709090A,$90A0C0D
  858.         dc.l    $6070708,$709090C,$90A0C0E,$6070809,$7090A0C,$90B0D0F
  859.         dc.l    $6070808,$70A0B0B,$90C0D10,$6080809,$70B0C0C,$90D0E11
  860.  
  861. atntab2:    dc.l    $2060E,$1020304
  862.  
  863. atntab3:    dc.l    $1010101,$2030304,$405070E
  864.  
  865. atntab4:    dc.l    $20002
  866.         dc.l    $20002
  867.         dc.l    $6000A
  868.         dc.l    $A0012
  869.         dc.l    $16002A
  870.         dc.l    $8A4012
  871.  
  872.         cnop    0,4
  873. atn28:        move.l    $22(a6),a5
  874.         move.l    14(a6),d4
  875.         move.l    a5,d0
  876.         addq.l    #1,d0
  877.         add.l    $1A(a6),d0
  878.         cmp.l    d4,d0
  879.         bls.s    atn29
  880.         move.l    d4,d0
  881.         move.l    d0,d1
  882.         sub.l    a5,d1
  883.         cmp.l    #3,d1
  884.         bcc.s    atn29
  885.         moveq    #0,d0
  886.         rts
  887.  
  888.         cnop    0,4
  889. atn29:        move.l    d0,d5
  890.         move.l    a5,a2
  891.         addq.l    #1,a2
  892.         move.l    a2,a4
  893.         moveq    #1,d7
  894.         move.b    (a5),d3
  895.  
  896.         lea    $34(a6),a3
  897. atn30:        cmp.b    (a2)+,d3
  898.         beq.s    atn32
  899.         cmp.b    (a2)+,d3
  900.         beq.s    atn32
  901.         cmp.b    (a2)+,d3
  902.         beq.s    atn32
  903.         cmp.b    (a2)+,d3
  904.         beq.s    atn32
  905.         cmp.b    (a2)+,d3
  906.         beq.s    atn32
  907.         cmp.b    (a2)+,d3
  908.         beq.s    atn32
  909.         cmp.b    (a2)+,d3
  910.         beq.s    atn32
  911.         cmp.b    (a2)+,d3
  912.         beq.s    atn32
  913.         cmp.b    (a2)+,d3
  914.         beq.s    atn32
  915.         cmp.b    (a2)+,d3
  916.         beq.s    atn32
  917.         cmp.b    (a2)+,d3
  918.         beq.s    atn32
  919.         cmp.b    (a2)+,d3
  920.         beq.s    atn32
  921.         cmp.b    (a2)+,d3
  922.         beq.s    atn32
  923.         cmp.b    (a2)+,d3
  924.         beq.s    atn32
  925.         cmp.b    (a2)+,d3
  926.         beq.s    atn32
  927.         cmp.b    (a2)+,d3
  928.         beq.s    atn32
  929.         cmp.l    a2,d5
  930.         bhi.s    atn30
  931.  
  932. atn31:        moveq    #-1,d0
  933.         rts
  934.  
  935.         cnop    0,4
  936. atn32:        cmp.l    a2,d5
  937.         bls.s    atn31
  938.         move.l    a4,a0
  939.         move.l    a2,a1
  940.         cmpm.b    (a0)+,(a1)+
  941.         bne.s    atn30
  942.         cmpm.b    (a0)+,(a1)+
  943.         bne.s    atn35
  944.         cmpm.b    (a0)+,(a1)+
  945.         bne.s    atn34
  946.  
  947.         move.w    #252-1,d0
  948. atn33:        cmpm.b    (a0)+,(a1)+
  949.         dbne    d0,atn33
  950.  
  951. atn34:        cmp.l    d4,a1
  952.         bls.s    atn35
  953.         move.l    d4,a1
  954.  
  955. atn35:        move.l    a1,d6
  956.         sub.l    a2,d6
  957.         cmp.w    d6,d7
  958.         bcc.s    atn30
  959.         move.w    d6,d7
  960.         cmp.w    #8,d6
  961.         bhi.s    atn36
  962.         tst.b    -2(a3,d6.w)
  963.         bne.w    atn30
  964.         move.b    d6,-2(a3,d6.w)
  965.         move.l    a2,d0
  966.         sub.l    a5,d0
  967.         subq.l    #2,d0
  968.         move.w    d6,d1
  969.         lsl.w    #2,d1
  970.         move.l    d0,0(a3,d1.w)
  971.         bra.w    atn30
  972.  
  973.         cnop    0,4
  974. atn36:        move.b    d6,7(a3)
  975.         move.l    a2,d0
  976.         sub.l    a5,d0
  977.         subq.l    #2,d0
  978.         move.l    d0,$24(a3)
  979.         cmp.b    #$FF,d6
  980.         bne.w    atn30
  981.         bra.s    atn31
  982.  
  983.         cnop    0,4
  984. atn37:        move.b    $2C(a6),d2
  985.         move.b    $2D(a6),d3
  986.         move.l    $26(a6),a0
  987. atn38:        lsr.l    #1,d1
  988.         roxr.b    #1,d2
  989.         subq.b    #1,d3
  990.         bpl.s    atn39
  991.         moveq    #7,d3
  992.         move.b    d2,(a0)+
  993.         moveq    #0,d2
  994. atn39:        subq.b    #1,d0
  995.         bne.s    atn38
  996.         move.l    a0,$26(a6)
  997.         move.b    d3,$2D(a6)
  998.         move.b    d2,$2C(a6)
  999.         rts
  1000.  
  1001.         cnop    0,4
  1002. atn40:        and.l    #$FF,d0
  1003.         cmp.b    #13,d0
  1004.         bhi.s    atn42
  1005.         cmp.b    #5,d0
  1006.         bhi.s    atn41
  1007.         lea    atntab2(pc),a0
  1008.         move.b    -2(a0,d0.w),$71(a6)
  1009.         move.b    2(a0,d0.w),$69(a6)
  1010.         bra.s    atn44
  1011.  
  1012.         cnop    0,4
  1013. atn41:        subq.b    #6,d0
  1014.         or.b    #$F0,d0
  1015.         move.b    d0,$71(a6)
  1016.         move.b    #8,$69(a6)
  1017.         bra.s    atn43
  1018.  
  1019.         cnop    0,4
  1020. atn42:        move.b    #$1F,$70(a6)
  1021.         move.b    d0,$71(a6)
  1022.         move.b    #13,$69(a6)
  1023. atn43:        moveq    #5,d0
  1024. atn44:        subq.b    #2,d0
  1025.         move.l    $30(a6),d2
  1026.         lea    atntab3(pc),a1
  1027.         lea    atntab4(pc),a0
  1028.         add.l    d0,a0
  1029.         add.l    d0,a0
  1030.         cmp.w    (a0),d2
  1031.         bcc.s    atn45
  1032.         move.b    0(a1,d0.w),d6
  1033.         move.b    d6,d3
  1034.         addq.b    #1,d3
  1035.         sf $73(a6)        ;move.b    #0,$73(a6)
  1036.         moveq    #0,d4
  1037.         bra.s    atn48
  1038.  
  1039.         cnop    0,4
  1040. atn45:        cmp.w    8(a0),d2
  1041.         bcc.s    atn46
  1042.         move.b    4(a1,d0.w),d6
  1043.         move.b    d6,d3
  1044.         addq.b    #2,d3
  1045.         move.b    #2,$73(a6)
  1046.         move.w    (a0),d4
  1047.         bra.s    atn48
  1048.  
  1049.         cnop    0,4
  1050. atn46:        cmp.w    $10(a0),d2
  1051.         blo.s    atn47
  1052.         moveq    #0,d0
  1053.         rts
  1054.  
  1055.         cnop    0,4
  1056. atn47:        move.b    8(a1,d0.w),d6
  1057.         move.b    d6,d3
  1058.         addq.b    #2,d3
  1059.         move.b    #3,$73(a6)
  1060.         move.w    8(a0),d4
  1061. atn48:        move.b    d3,$6A(a6)
  1062.         sub.w    d4,d2
  1063.         moveq    #$10,d5
  1064.         sub.b    d6,d5
  1065.         lsl.w    d5,d2
  1066. atn49:        add.w    d2,d2
  1067.         roxl    $72(a6)
  1068.         subq.b    #1,d6
  1069.         bne.s    atn49
  1070.         lea    $A4(a6),a1
  1071.         lea    $74(a6),a0
  1072.         add.w    d0,a0
  1073.         add.w    d0,a0
  1074.         add.w    d0,a0
  1075.         add.w    d0,a0
  1076.  
  1077.         cmp.l    (a0),d1
  1078.         bcc.s    atn50
  1079.         move.b    0(a1,d0.w),d6
  1080.         move.b    d6,d3
  1081.         addq.b    #1,d3
  1082.         moveq    #0,d7
  1083.         move.l    d7,d4
  1084.         bra.s    atn53
  1085. atn50:        cmp.l    $10(a0),d1
  1086.         bcc.s    atn51
  1087.         move.b    4(a1,d0.w),d6
  1088.         move.b    d6,d3
  1089.         addq.b    #2,d3
  1090.         moveq    #2,d7
  1091.         move.l    (a0),d4
  1092.         bra.s    atn53
  1093. atn51:        cmp.l    $20(a0),d1
  1094.         blo.s    atn52
  1095.         moveq    #0,d0
  1096.         rts
  1097.  
  1098.         cnop    0,4
  1099. atn52:        move.b    8(a1,d0.w),d6
  1100.         move.b    d6,d3
  1101.         addq.b    #2,d3
  1102.         moveq    #3,d7
  1103.         move.l    $10(a0),d4
  1104. atn53:        move.b    d3,$68(a6)
  1105.         sub.l    d4,d1
  1106.         moveq    #$20,d5
  1107.         sub.b    d6,d5
  1108.         lsl.l    d5,d1
  1109. atn54:        add.l    d1,d1
  1110.         addx.l    d7,d7
  1111.         subq.b    #1,d6
  1112.         bne.s    atn54
  1113.         move.l    d7,$6C(a6)
  1114.  
  1115.         moveq    #-1,d0
  1116.         rts
  1117.  
  1118.         cnop    0,4
  1119. atn55:        clr.w    $2A(a6)
  1120.         clr.b    $2E(a6)
  1121.         lea    $34(a6),a4
  1122.         lea    $3C(a6),a5
  1123. atn56:        move.l    (a5)+,d1
  1124.         move.b    (a4)+,d0
  1125.         beq.s    atn58
  1126.  
  1127.         bsr.w    atn40
  1128.         beq.s    atn58
  1129.  
  1130.         moveq    #0,d0
  1131.         moveq    #0,d1
  1132.         move.b    -1(a4),d0
  1133.         lsl.w    #3,d0
  1134.         add.b    $69(a6),d1
  1135.         add.b    $68(a6),d1
  1136.         add.b    $6A(a6),d1
  1137.         sub.w    d1,d0
  1138.         bmi.s    atn58
  1139.  
  1140.         cmp.w    $2A(a6),d0
  1141.         blo.s    atn58
  1142.         move.w    d0,$2A(a6)
  1143.         move.b    -1(a4),$2E(a6)
  1144.  
  1145.         lea    $5C(a6),a0
  1146.         lea    $68(a6),a1
  1147.         moveq    #13-1,d1
  1148. atn57:        move.b    (a1)+,(a0)+
  1149.         dbf    d1,atn57
  1150.  
  1151. atn58:        move.l    a4,d0
  1152.         sub.l    a6,d0
  1153.         cmp.w    #$3C,d0
  1154.         bne.s    atn56
  1155.         clr.l    -(a4)
  1156.         clr.l    -(a4)
  1157.         tst.w    $2E(a6)
  1158.         rts
  1159.  
  1160. H2H:        movem.l    d1-d2/a0-a1,-(sp)
  1161.         addq.l    #8,a0
  1162.         lea     hextab(pc),a1
  1163.         moveq   #8-1,d1
  1164. NextByte:    move.l    d0,d2
  1165.         and.l    #15,d2
  1166.         move.b    0(a1,d2.w),-(a0)
  1167.         lsr.l    #4,d0
  1168.         dbra    d1,NextByte
  1169.         movem.l    (sp)+,d1-d2/a0-a1
  1170.         rts
  1171.  
  1172. About.txt    dc.b    $1b,'c',$a
  1173.         dc.b    $1b,'[1mIMP!',$1b,'[22m ',$1b,'[33mData-Packer ',$1b,'[32m1.01',$1b,'[3m',$1b,'[31mQuick FrontEnd',$1b,'[23m',$1b,'[3m(Imploder Algorithm)',$1b,'[23m',$1b,'[3m',$1b,'[23m',$a
  1174.         dc.b    'Copyright © 1996. All Rights Are Reserved.',$a
  1175.         dc.b    'Assembly Date: Jan-96.',$a,$a
  1176.         dc.b    'NB: While packing use CTRL+C to abort the entire session!',$a,0
  1177. LFs.Txt:
  1178. LF.txt        dc.b    10,0
  1179. Load.txt    dc.b    10,'Loading file.. ',0
  1180. Save.txt    dc.b    10,'Saving file.. ',0
  1181. Packing.txt:    dc.b    10,'Packing file...',10
  1182.         dc.b    'Please wait..',10,0
  1183. NoPath.txt:    dc.b    10,'No Destination Path Specified!',10,0
  1184. ErrorMem.txt:    dc.b    'Error: Out Of Memory...',0
  1185. ErrorLoad.txt    dc.b    'Error: Skipping file, failed to load..',10,0
  1186. ErrorSave.txt    dc.b    'Error: Skipping file, failed to save..',10,0
  1187. ErrorGain.txt:    dc.b    'Error: Skipping file, No gain!!',10,0
  1188. OrigLength.Txt:    dc.b    10,'Original Data Length : ',0
  1189. PakLength.Txt:    dc.b    'Packed Data Length   : ',0
  1190. Gained.Txt:    dc.b    'Gained Bytes         : ',0
  1191. Percentage.Txt:    dc.b    'Percentage Gain      : ',0
  1192. TotGain.Txt:    dc.b    10,'Total Gain           : ',0
  1193. Done.txt:    dc.b    10,'Session Done...',10,0
  1194. Text89        dc.b    "Select Destination Path..",0
  1195. Text66        dc.b    "Select File(s)...",0
  1196.         even
  1197. Tags9        dc.l    RTFI_Flags,FREQF_MULTISELECT
  1198.         dc.l    TAG_END
  1199. Tags11        dc.l    RTFI_Flags,FREQF_NOFILES
  1200.         dc.l    TAG_END
  1201. DOSName        dc.b    'dos.library',0
  1202. ReqName        dc.b    'reqtools.library',0
  1203.         cnop    0,2
  1204. hextab        dc.b    '0123456789ABCDEF'
  1205.  
  1206.